//
//  ST_MatchFaceFailureController.swift
//  btvideo
//
//  Created by mac on 2020/3/18.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift
import SnapKit

class ST_MatchFaceFailureController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        view.addSubview(root_view)
        root_view.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.width.equalTo(240)
            make.height.equalTo(280)
        }
        
        root_view.addSubview(imageView)
        imageView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(32)
            make.centerX.equalToSuperview()
        }
        
        root_view.addSubview(match_title_label)
        match_title_label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(imageView.snp.bottom).offset(17)
        }
        root_view.addSubview(match_sub_title_label)
        match_sub_title_label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(match_title_label.snp.bottom).offset(10)
        }
        
        root_view.addSubview(confirm_btn)
        confirm_btn.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(match_sub_title_label.snp.bottom).offset(17)
            make.width.equalTo(160)
            make.height.equalTo(35)
        }
        
        root_view.addSubview(cancel_btn)
        cancel_btn.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(confirm_btn.snp.bottom).offset(5)
            make.width.height.equalTo(confirm_btn)
        }
        
    }

    //    MARK: - Properties
    
    fileprivate lazy var root_view:UIView = {
       let control = UIView()
        control.backgroundColor = .white
        control.cornerRadius = 20
        return control
    }()
    
    
    fileprivate lazy var imageView:UIImageView = {
       let control = UIImageView()
        control.image = ST_ImageUtils.imageName("个人中心_img_认证失败")
        return  control
    }()
    
    fileprivate lazy var match_title_label:UILabel = {
       let label = UILabel()
       let attrString = NSMutableAttributedString(string: "认证失败")
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 18, weight: UIFont.Weight.medium),.foregroundColor: UIColor(red: 0.4, green: 0.4, blue: 0.4, alpha: 1)]
       attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        label.attributedText = attrString
       return label
    }()

    fileprivate lazy var match_sub_title_label:UILabel = {
       let label = UILabel()
        label.numberOfLines = 0
       let attrString = NSMutableAttributedString(string: "真人识别已完成，但是头像照片与\n你的真人识别不符，请重新尝试。")
        
        let parag = NSMutableParagraphStyle()
        parag.alignment = .center
        parag.lineSpacing = 5
        
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular),.foregroundColor: UIColor.init(hexString: "#61666F")!,.paragraphStyle:parag]
       attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        
        label.attributedText = attrString
       return label
    }()
    
    fileprivate lazy var confirm_btn:UIButton = {
            
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.backgroundColor = Color.init(hexString: "#FEC207")
        control.cornerRadius = 36/2.0
        control.setTitleForAllStates("使用其他照片")
        control.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.semibold)
        control.setTitleColorForAllStates(UIColor.white)
        control.addTarget(self, action: #selector(confirm_handle), for: UIControl.Event.touchUpInside)
        return control
    }()
    
    fileprivate lazy var cancel_btn:UIButton = {
            
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.setTitleForAllStates("稍后再说")
        control.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)
        control.setTitleColorForAllStates(UIColor.init(hexString: "#61666F")!)
        control.addTarget(self, action: #selector(cancel_handle), for: UIControl.Event.touchUpInside)
        return control
    }()
    
    
    
}

extension ST_MatchFaceFailureController{
    
    @objc func confirm_handle(){
        
        goback_previous_controller(animated: true) {
            
            
            GlobalPresent(toController: ST_MyPhotoViewController())
//            ST_AIMycenterViewController.shared.navigationController?.pushViewController(ST_MyPhotoViewController())
        }
    }
    
    @objc func cancel_handle(){
        
        goback_previous_controller()
    }
}
